<template>
	<view class="address-page">		
			<!-- <free-nav-bar textContent="地址管理" isBackShow></free-nav-bar> -->
			<view class="address-list" id="head" :style="{height: scrollerHeight + 'px'}">
				<address-list-item :list-data="myAddrList" :show-wei-xin-addr="false"  :min-height="640"
					@close-addres-list="closeAddresList"
					@select-address="selectAddress" :show-title="false"></address-list-item>
			</view>			
	</view>
</template>

<script>
	import freeNavBar from "@/components/free-ui/free-nav-bar.vue"
	import $U from '@/common/free-lib/util.js';
	import $H from '@/common/free-lib/request.js';
	import addressListItem from "@/components/free-ui/address-list-item.vue"
	export default {
		components: {
			freeNavBar,
			addressListItem
		},
		data() {
			return {
				phoneHeight: 0, //屏幕可用高度
				topHeight: 0, //滑块上方高度
				bottomHeight: 0, //底部高度
				scrollerHeight:0,
				scrollTop: 0,
				old: {
					scrollTop: 0
				},
				myAddrList:[]
			}
		},
		onShow() {
			this.getMyAddressList();
		},
		onReady() {
			var height;
			var _this = this;
			uni.getSystemInfo({
				success: function(res) {
					_this.phoneHeight = res.windowHeight;
					_this.$nextTick(() => {
						let view = uni.createSelectorQuery().select("#head"); //局部滑块
						view.boundingClientRect(data => {
							_this.topHeight = data.height;
							height = _this.phoneHeight - _this.topHeight - 44;	
							_this.scrollerHeight = height;
						}).exec();
					})
				},
			}); 
			this.scrollerHeight = height;
		},
		methods: {
			getMyAddressList() {
				  let _this = this;
				  $H.get('/member/address/list').then(res => {
					 if(res) {
						_this.myAddrList = res;						
					 }
				  })
			},
			editHandle(item) {				
				uni.navigateTo({url: '/pages/my/add-address?address=' + JSON.stringify(item)});
			},
			selectAddress(e) {
				this.editHandle(e);
			},
			goAddAddress() {
				uni.navigateTo({url: '/pages/my/add-address'});
			}
		}
	}
</script>

<style lang="scss" scoped>
.slot-box /deep/ .uni-tag--primary {
	background-color: #FD5052 ;
	border-color:#FD5052 ;
}
.address-page {
	position: relative;
	overflow-y: hidden;
	padding-bottom: calc(env(safe-area-inset-bottom) + 100rpx);
	background: #F4F4F4;
	/deep/ .uni-list {
		background: #F4F4F4;
	}
	.address-list {
		position: relative;
		width: 100%;
		min-height: 260rpx;
		background: #F4F4F4;		
	}
	.address-bottom {
		position: fixed;
		width: 100%;
		bottom: calc(env(safe-area-inset-bottom) + 100rpx);
		left: 0;
		background: #fff;
		border-top: 1px solid #F4F4F4;
		padding: 0rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		box-sizing: border-box;
	}
}
</style>
